﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;

namespace WebApp.Code
{
    public class FolderManager
    {
        public FolderManager(string path)
        {
            Path = path;
        }

        public string Path { get; set; }

        public List<FileManager> Files
        {
            get 
            {  
                List<FileManager> list=new List<FileManager>();

                List<string> folders = System.IO.Directory.GetDirectories(Path).ToList();
                folders.Sort();
                foreach (var item in folders)
                {
                    list.Add(new FileManager(FileType.Folder, item));
                }

                List<string> files = System.IO.Directory.GetFiles(Path).ToList();
                files.Sort();
                foreach (var item in files)
                {
                    list.Add(new FileManager(FileType.File, item));
                }
                return list;
            }
        }


        public bool IsAccess
        {
            get { return System.IO.Directory.GetAccessControl(Path).AreAccessRulesCanonical; }
        }
    }
}